/**
 * Copyright (C), 2015-2024, XXX有限公司
 * FileName: KafkaProducter
 * Author:   Administrator
 * Date:     2024/3/27 21:11
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */

import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.clients.producer.ProducerRecord;

import java.util.HashMap;
import java.util.Map;

/**
 * 〈一句话功能简述〉<br>
 * 〈〉
 *
 * @author Administrator
 * @create 2024/3/27
 * @since 1.0.0
 */
public class KafkaProducerTest {

    public static void main(String[] args) {
        //TODO 创建生产者

        Map<String, Object> config = new HashMap<String, Object>();
        config.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "113.249.93.63:9092");
        config.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer");
        config.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer");
        KafkaProducer<String, String> producer = new KafkaProducer<String, String>(config);
        // TODO 生产数据
        ProducerRecord<String, String> record = new ProducerRecord<String, String>("test", "key", "value");
        // TODO 发送数据
        producer.send(record);
        // TODO 关闭生产者
        producer.close();

    }

}